package com.haha.im

import android.os.Handler
import com.haha.im.contract.SplashContract
import com.haha.im.presenter.SplashPresenter
import org.jetbrains.anko.startActivity

class SplashActivity :BaseActivity(),SplashContract.View{

    val presenter = SplashPresenter(this)
    companion object{
        val DELAY = 2000L
    }

    val handler by lazy { Handler() }

    override fun getLayoutResId(): Int =
        R.layout.activity_splash


    init {
        presenter.checkLoginStatus()
    }
    //延时2s，跳转到登录页面
    override fun onNotLoggedIn() {
       handler.postDelayed({
           startActivity<LoginActivity>()
           finish()
       }, DELAY)
    }

    //跳转到主界面
    override fun onLoggedIn() {
        startActivity<MainActivity>()
        finish()
    }


}